/*
 * This file is part of GuitarMaster.
 * 
 * GuitarMaster is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * GuitarMaster is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with Foobar.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.paris5.master2.guitarmaster.entity;

import com.paris5.master2.guitarmaster.bean.EcomCartRow;
import java.io.Serializable;
import javax.persistence.*;

/**
 *
 * @author Leticia Mahamed, Alice Khammy, mourad nedjahi, Saliou Mamadou Barry
 */
@Entity
@Table(name = "cart_row")
public class CartRow implements Serializable {

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id_cart_row")
    private Integer idCartRow;
    @Column(name = "price")
    private Float price;
    @Column(name = "quantity")
    private Integer quantity;
    @JoinColumn(name = "id_product", referencedColumnName = "id_product_type")
    @ManyToOne
    private ProductType product;
    @JoinColumn(name = "id_cart", referencedColumnName = "id_cart")
    @ManyToOne
    private CartE cart;

    public EcomCartRow getEcomCartRow() {
        EcomCartRow eCartRow = new EcomCartRow();
        eCartRow.setIdCartRow(this.idCartRow);
        eCartRow.setProduct(this.product.getEcomProductType());
        eCartRow.setQuantity(this.quantity);
        eCartRow.setPrice(this.price);
        return eCartRow;
    }

    public Integer getIdCartRow() {
        return idCartRow;
    }

    public Float getPrice() {
        return price;
    }

    public ProductType getProduct() {
        return product;
    }

    public Integer getQuantity() {
        return quantity;
    }

    public void setIdCartRow(Integer idCartRow) {
        this.idCartRow = idCartRow;
    }

    public void setPrice(Float price) {
        this.price = price;
    }

    public void setProduct(ProductType product) {
        this.product = product;
    }

    public void setQuantity(Integer quantity) {
        this.quantity = quantity;
    }

    public CartE getCart() {
        return cart;
    }

    public void setCart(CartE cart) {
        this.cart = cart;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCartRow != null ? idCartRow.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof CartRow)) {
            return false;
        }
        CartRow other = (CartRow) object;
        if ((this.idCartRow == null && other.idCartRow != null) || (this.idCartRow != null && !this.idCartRow.equals(other.idCartRow))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.paris5.master2.guitarmaster.entity.CartRow[ id=" + idCartRow + " ]";
    }
}
